//
// Copyright (c) 2009 All Right Reserved
//
// vl
//
// 2009-01-01
// Contains ...
using System.Globalization;
using System.Text;
using JetBrains.Annotations;
namespace LargoCommon.Music
{
///
/// Editor Point.
///
public struct MusicalPoint {
#region Constructors
///
/// Initializes a new instance of the struct.
///
/// Index of the given line.
/// The given bar number.
public MusicalPoint(int givenLineIndex, int givenBarNumber)
: this()
{
this.LineIndex = givenLineIndex;
this.BarNumber = givenBarNumber;
}
#endregion
#region Properties
///
/// Gets the bar number.
///
///
/// The bar number.
///
public int BarNumber { get; }
///
/// Gets the line number.
///
///
/// The line number.
///
public int LineIndex { get; }
///
/// Gets Elements the identifier.
///
/// Property description.
/// Returns value.
public string Identifier {
get
{
var ident = string.Format(CultureInfo.CurrentCulture, "{0}#{1}", this.LineIndex, this.BarNumber);
return ident;
}
}
///
/// Gets a value indicating whether this instance is valid.
///
///
/// True if this instance is valid; otherwise, false.
///
public bool IsDefined => this.BarNumber > 0 && this.LineIndex >= 0;
///
/// Gets a value indicating whether this instance is empty.
///
///
/// true if this instance is empty; otherwise, false.
///
public bool IsEmpty => this.BarNumber == 0 || this.LineIndex < 0;
#endregion
#region Public Static
///
/// Gets the point.
///
/// The line.
/// The bar.
/// Returns value.
public static MusicalPoint GetPoint(int line, int bar) {
return new MusicalPoint(line, bar);
//// var p = this.IsMainArea(line, bar) ? this.points[line, bar] : new MusicalPoint(line, bar);
//// return p;
}
#endregion
#region String representation
///
/// Returns a that represents this instance.
///
///
/// A that represents this instance.
///
public override string ToString() {
return this.Identifier;
}
/// String representation of the object.
/// Returns value.
[UsedImplicitly]
public string ToDisplayString() {
var s = new StringBuilder();
s.AppendFormat(
" Bar {0} line {1}", this.BarNumber, this.LineIndex);
return s.ToString();
}
#endregion
}
}